﻿/*
   绑定视图：DictionaryView.xaml
   文件说明：数据字典业务层
*/


using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using ZFS.Model;
using ZFSData;
using ZFSData.InterFace;
using ZFSDomain.Common.CoreLib;
using ZFSDomain.Interface.User;
using ZFSDomain.Service;
using ZFSDomain.SysModule;

namespace ZFSDomain.ViewModel.Dictionary
{
    /// <summary>
    /// 数据字典
    /// </summary>
    public class DictionaryViewModel : BaseOperation<tb_Dictionary>
    {
        public override async void GetPageData(int pageIndex)
        {
            try
            {
                IDictionary user = ZFSBridge.BridgeFactory.GetDictionaryBridge();

                int total = 0;
                var UserList = await Task.Run(() => user.GetPagingModels(pageIndex, PageSize, out total,
                    new tb_Dictionary() { DataCode = SearchText, NativeName = SearchText }));

                TotalCount = total;
                GridModelList.Clear();
                UserList.ForEach((arg) => GridModelList.Add(arg));
                base.SetPageCount();
            }
            catch (Exception ex)
            {
                Msg.Error(ex);
            }
        }

        public override void Add<TModel>(TModel model)
        {
            try
            {
                DictionaryDialogViewModel view = new DictionaryDialogViewModel();

                var dialog = ServiceProvider.Instance.Get<IDictionaryDialog>();
                dialog.BindViewModel(view);
                var result = dialog.ShowDialog();
                if (result.HasValue && result.Value)
                {

                }
            }
            catch (Exception ex)
            {
                Msg.Error(ex);
            }
        }

        public override void Edit<TModel>(TModel model)
        {
            throw new NotImplementedException();
        }

        public override void Del<TModel>(TModel model)
        {
            throw new NotImplementedException();
        }
    }
}
